"""
应用配置
"""

import os


class Config:
    """基础配置"""
    
    # Flask 配置
    ENV = os.getenv('FLASK_ENV', 'production')
    DEBUG = ENV == 'development'
    SECRET_KEY = os.getenv('SECRET_KEY', 'dev-secret-key-change-it')
    
    # 服务器配置
    HOST = '0.0.0.0'  # 默认配置
    PORT = int(os.getenv('PORT', 5000))
    
    # AI API 配置
    AI_API_BASE_URL = os.getenv('AI_API_BASE_URL', 'https://dashscope.aliyuncs.com/compatible-mode/v1')
    AI_API_KEY = os.getenv('AI_API_KEY', '')
    AI_API_TIMEOUT = int(os.getenv('AI_API_TIMEOUT', 30))  # 秒
    
    # CORS 配置
    CORS_ORIGINS = os.getenv('CORS_ORIGIN', 'http://localhost:80').split(',')
    
    # API Key 保护（可选）
    INTERNAL_API_KEY = os.getenv('INTERNAL_API_KEY', '')
    
    # 默认 AI 模型配置
    DEFAULT_MODEL = os.getenv('DEFAULT_MODEL', 'qwen-plus')
    DEFAULT_TEMPERATURE = float(os.getenv('DEFAULT_TEMPERATURE', 0.7))
    DEFAULT_MAX_TOKENS = int(os.getenv('DEFAULT_MAX_TOKENS', 2000))


class DevelopmentConfig(Config):
    """开发环境配置"""
    DEBUG = True
    ENV = 'development'
    HOST = '0.0.0.0'  


class ProductionConfig(Config):
    """生产环境配置"""
    DEBUG = False
    ENV = 'production'
    HOST = '127.0.0.1' 


# 根据环境选择配置
config = {
    'development': DevelopmentConfig,
    'production': ProductionConfig,
    'default': Config
}
